package com.seguriapp.entities;

import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import com.seguriapp.base.BaseEntity;
import com.seguriapp.util.Util;

/**
 * Represents a User entity.
 * 
 * @author Tania Gonzales(taniadgv@gmail.com)
 */
@Entity
@Table(name = "User")
public class User extends BaseEntity {

  private static final long serialVersionUID = -32435165889577406L;
  @Id
  @GeneratedValue
  private Long id;

  private String username;
  private String password;
  private boolean administrator;
  private Date lastDateLoggedIn;

  public Long getId() {
    return id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public String getUsername() {
    return username;
  }

  public void setUsername(final String username) {
    this.username = username;
  }

  public String getPassword() {
    return password;
  }

  public void setPassword(final String password) {
    this.password = password;
  }

  public boolean isAdministrator() {
    return administrator;
  }

  public void setAdministrator(final boolean administrator) {
    this.administrator = administrator;
  }

  public Date getLastDateLoggedIn() {
    return lastDateLoggedIn;
  }

  public void setLastDateLoggedIn(final Date lastDateLoggedIn) {
    this.lastDateLoggedIn = lastDateLoggedIn;
  }

  public Map<String, Object> toJsonString() {
    final Map<String, Object> map = new LinkedHashMap<String, Object>();
    map.put("id", id);
    map.put("username", username);
    map.put("administrator", administrator);
    map.put("lastDateLoggedIn", Util.parseDateToString(lastDateLoggedIn));
    return map;
  }

}
